package com.future.mayi.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class PriceUtils {


    public static double getMultiply(double x, double y) {
        BigDecimal x1 = new BigDecimal(Double.valueOf(x));
        BigDecimal y1 = new BigDecimal(Double.valueOf(y));
        return x1.multiply(y1).doubleValue();
    }


    public static String getPriceText(double money) {
        if (money == 0) return "0";
        return String.valueOf(new BigDecimal(money).setScale(0, BigDecimal.ROUND_HALF_UP));
    }

    public static String getPriceText2(double money) {
        if (money == 0) return "0.00";
        DecimalFormat df = new DecimalFormat("#0.00");
//        return new BigDecimal(money).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "";
        return df.format(money);
    }
}
